package com.bjnangle.nangletool;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.bjnangle.nangletool.utils.PlayerManager;


/**
 * Created by YFB on 2017/8/18.
 */

public class SpeakActivity extends BaseActivity {
    private ToggleButton toggleButton;
    private PlayerManager playerManager;
    private static String PATH = "android.resource://";
    private TextView tvTitle;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_speak);
        toggleButton = (ToggleButton) findViewById(R.id.tgb);
        playerManager = PlayerManager.getManager(this);
        PATH = PATH + getPackageName() + "/" + R.raw.blm;
        playerManager.play(PATH,callback);
        toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if(b){
                    playerManager.changeToSpeakerMode();
                }else{
                    playerManager.changeToEarpieceMode();
                }
            }
        });
        setActivity(this);
        ivGoBack = (ImageView)findViewById(R.id.btn_back);
        tvTitle = (TextView)findViewById(R.id.tv_title);
        tvTitle.setText("听筒外放设置");
    }



    @Override
    public void onStop() {
        super.onStop();
        playerManager.stop();
    }
    private PlayerManager.PlayCallback callback = new PlayerManager.PlayCallback() {
        @Override
        public void onPrepared() {

        }

        @Override
        public void onComplete() {

        }

        @Override
        public void onStop() {

        }
    };

}
